import request from '@/utils/request'
const loginBaseApi = process.env.Login_BASE_API
const api = {
  /*
  *  登录(这个传参特殊点,不要参考)
  * */
  loginByUsername(params) {
    let url = loginBaseApi + '/api/v1/login';
    const paramsArr = [];
    for (const key in params) {
      const val = params[key];
      paramsArr.push(`${key}=${val}`);
    }
    url = url + '?' + paramsArr.join('&');
    return request({
      url: url,
      method: 'POST'
    })
  },
  /*
  *  登出
  * */
  logout(params) {
    return request({
      url: loginBaseApi + '/api/v1/auth/logout',
      method: 'POST',
      params
    })
  },

  getUserInfoByToken(params, headers){
    return request({
     url: loginBaseApi + `/api/v1/auth/getUserInfoByToken?projectCode=${params.projectCode}&projectId=${params.projectId}`,
      method: 'POST',
      params,
      headers
    })
  }
}
export default api;
